<template>
  <div>
    <div class="mb-16px">
      <el-button type="primary" @click="handleCreate">新增模型</el-button>
    </div>
    <div>
      <el-table :data="tableData" border>
        <el-table-column prop="identifier" label="标识" width="180"></el-table-column>
        <el-table-column prop="name" label="模型名称" width="180">
          <template #default="{ row }">
            <RouterLink :to="`/model/${row.identifier}`">{{ row.name }}</RouterLink>
          </template>
        </el-table-column>
        <el-table-column prop="remark" label="备注" width="180"></el-table-column>
        <el-table-column prop="systemRequired" label="系统模型" width="180">
          <template #default="{ row }">
            <el-tag v-if="row.systemRequired === '1'">是</el-tag>
            <el-tag v-else>否</el-tag>
          </template>
        </el-table-column>
      </el-table>
    </div>
  </div>
</template>
<script setup lang="ts">
import { ref, onMounted } from 'vue'
import { queryModelById, createModel, queryModelList } from '@/api/model/index'
import { useRouter } from 'vue-router'

const router = useRouter()

const tableData = ref<any[]>([

])
const handleCreate = () => {
  router.push('/model/create')
}

const getModelList = async () => {
  const res: any = await queryModelList({})
  if (res.code === 0) {
    tableData.value = [...res.data]
  }
}

onMounted(() => {
  getModelList()
})

</script>
<style scoped></style>
